angular.module('app').service('libLoad',['JQ_CONFIG', 'MODULE_CONFIG',function(JQ_CONFIG, MODULE_CONFIG){
	alert(0);
	this.load = function(srcs, callback){
		return {
	        deps: ['$ocLazyLoad', '$q',
	          function( $ocLazyLoad, $q ){
	            var deferred = $q.defer();
	            var promise  = false;
	            srcs = angular.isArray(srcs) ? srcs : srcs.split(/\s+/);
	            if(!promise){
	              promise = deferred.promise;
	            }
	            angular.forEach(srcs, function(src) {
	              promise = promise.then( function(){
	                if(JQ_CONFIG[src]){
	                  return $ocLazyLoad.load(JQ_CONFIG[src]);
	                }
	                angular.forEach(MODULE_CONFIG, function(module) {
	                  if( module.name == src){
	                    name = module.name;
	                  }else{
	                    name = src;
	                  }
	                });
	                return $ocLazyLoad.load(name);
	              } );
	            });
	            deferred.resolve();
	            return callback ? promise.then(function(){ return callback(); }) : promise;
	        }]
	    }
	}
}]);